#pragma once
#include"RBTree.h"
#include<vector>
#include<string>

namespace zy
{
	template<class K,class V>
	class map
	{
		struct MapKeyofT
		{
			const K& operator()(const pair<const K,V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<const K, V>, MapKeyofT>::Iterator iterator;
		typedef typename RBTree<K, pair<const K, V>, MapKeyofT>::Const_Iterator const_iterator;
		
		iterator begin()
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End();
		}

		const_iterator begin() const
		{
			return _t.Begin();
		}

		const_iterator end() const
		{
			return _t.End();
		}

		pair<iterator,bool> insert(const pair<const K, V>& kv)
		{
			return _t.Insert(kv);
		}

		iterator find(const K& k)
		{
			return _t.Find(k);
		}

		V& operator[](const K& k)
		{
			pair<iterator, bool> ret = _t.Insert(make_pair(k, V()));
			return ret.first->second;
		}

	private:
		RBTree<K, pair<const K, V> ,MapKeyofT> _t;
	};
}